package com.plian.system.controller.fr.indicatorsvalue;

import com.plian.system.model.R;
import com.plian.system.service.fr.indicatorsvalue.IIndicatorsReportService;
import com.plian.system.vo.fr.indicatorsValue.IndicatorsReportVO;
import com.plian.system.vo.zzd.finance.FinancingMonthDataVO;
import com.plian.system.vo.zzd.finance.IndicatorsYearDataVO;
import com.plian.system.vo.zzd.finance.RevenueMonthDataVO;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@AllArgsConstructor
@RestController
@RequestMapping(value = "api/indicators-report")
public class IndicatorsReportController {

    private IIndicatorsReportService indicatorsReportService;

    @GetMapping("/asset-indicators")
    @ApiOperation(value = "获取资产概况指标值")
    public R<List<IndicatorsReportVO>> getAssetIndicators(@RequestParam("propertyId") String propertyId,
                                                          @RequestParam(value = "date", required = false) String reportTime) {
        return R.data(indicatorsReportService.getAssetIndicators(propertyId, reportTime));
    }

    @GetMapping("/indicators-year-data")
    @ApiOperation("资产概况 历年趋势")
    public R<IndicatorsYearDataVO> getIndicatorsYearData(@RequestParam("propertyId") String propertyId,
                                                         @RequestParam("code") String code,
                                                         @RequestParam(value = "date", required = false) String reportTime) {
        return R.data(indicatorsReportService.getIndicatorsYearData(propertyId, code, reportTime));
    }

    @GetMapping("/operating-indicators")
    @ApiOperation(value = "获取经营成果指标值")
    public R<List<IndicatorsReportVO>> getOperatingIndicators(@RequestParam("propertyId") String propertyId,
                                                              @RequestParam(value = "date", required = false) String reportTime) {
        return R.data(indicatorsReportService.getOperatingIndicators(propertyId, reportTime));
    }

    @GetMapping("/year-revenue")
    @ApiOperation(value = "本年营收")
    public R<RevenueMonthDataVO> yearRevenue(@RequestParam("propertyId") String propertyId,
                                             @RequestParam(value = "date", required = false) String reportTime) {
        return R.data(indicatorsReportService.getYearRevenue(propertyId, reportTime));
    }

    @GetMapping("/financing/month-data")
    @ApiOperation(value = "融资 月度数据 code 融资成本率：financingCostRate 带息负债总额：interestBearingTotal \n" +
            "直接融资：directFinancing 间接融资：indirectFinancing 长期融资：longTermFinancing 短期融资：shortTermFinancing")
    public R<FinancingMonthDataVO> financingMonthData(@RequestParam("propertyId") String propertyId,
                                                      @RequestParam("startDate") String startDate,
                                                      @RequestParam("endDate") String endDate,
                                                      @RequestParam(value = "code", required = false) String code) {
        //todo 具体取数待实现
        return R.success();
    }
}
